package com.vict.bean;

import lombok.Data;

import java.io.Serializable;
import java.sql.Timestamp;

@Data
public class TaskExecuteInstance  implements Serializable {
    private static final long serialVersionUID = 4782965139950730568L;

    private String taskExecuteInstanceID;
    private String serverName;
    private String serverId;
    private String type;
    private Integer status; // '任务状态 0待执行 1执行中 2已完成 3已失败',
    public static final int status_await = 0;
    public static final int status_run = 1;
    public static final int status_finish = 2;
    public static final int status_fail = 3;

    private Integer executeCount;
    private Timestamp actionTime;
    private String executeJSON;
    private String stContext;
    private String linkTaskExecuteInstanceID;

    // 非数据库字段
    // private String actionTimeList;
    // private String taskExecuteInstanceIDList;
    // private String createdList;
    // private String statusList;
    // private String executeCountList;
    // private String executeJSONList;

    public static String convertStatus(String status) {
        if(status == null || status.trim().equals("")){
            return null;
        }
        switch (status) {
            case "待执行":
                return "0";
            case "执行中":
                return "1";
            case "已完成":
                return "2";
            case "已失败":
                return "3";
            case "0":
                return "待执行";
            case "1":
                return "执行中";
            case "2":
                return "已完成";
            case "3":
                return "已失败";
        }
        return null;
    }
}
